<?php

declare(strict_types=1);
namespace app\api\controller;


use app\BaseController;
use app\common\business\Sms as SmsBus;
class Sms extends BaseController
{
    public function code():object
    {
        $phone = input('param.phone','','trim');
        $data = [
            'phone' =>$phone,
        ];
        try{
            validate(\app\api\validate\ApiUser::class)->scene('send_code')->check($data);
        }catch (\think\exception\ValidateException $e){
           return show(config("status.error"),$e->getError());
        }
        if(SmsBus::sendCode($phone,6)){
            return show(config("status.success"),"发送验证码成功");
        }else{
            return show(config("status.error"),"发送验证码失败");
        }

    }
}